GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD,
null, null);
} catch (err) {
- if (err.code == GLib.SpawnError.G_SPAWN_ERROR_NOENT) {
- err.message = _("Command not found");
- } else {
+ /* Rewrite the error in case of ENOENT */
+ if (err.matches(GLib.SpawnError, GLib.SpawnError.NOENT)) {
+ throw new GLib.SpawnError({ code: GLib.SpawnError.NOENT,
+ message: _("Command not found") });
+ } else if (err instanceof GLib.Error) {
// The exception from gjs contains an error string like:
// Error invoking GLib.spawn_command_line_async: Failed to
// execute child process "foo" (No such file or directory)
// We are only interested in the part in the parentheses. (And
// we can't pattern match the text, since it gets localized.)
- err.message = err.message.replace(/.*\((.+)\)/, '$1');
+ let message = err.message.replace(/.*\((.+)\)/, '$1');
+ throw new (err.constructor)({ code: err.code,
+ message: message });
+ } else {
+ throw err;
}
-
- throw err;
}
// Dummy child watch; we don't want to double-fork internally
// because then we lose the parent-child relationship, which